#pragma once

namespace TradeIt {

	using namespace System;
	using namespace System::ComponentModel;
	using namespace System::Collections;
	using namespace System::Windows::Forms;
	using namespace System::Data;
	using namespace System::Drawing;

	/// <summary>
	/// Summary for frmLog
	/// </summary>
	public ref class frmLog : public System::Windows::Forms::Form
	{
	public:
		frmLog(Account ^account)
		{
			InitializeComponent();
			this->account = account;
			//
			//TODO: Add the constructor code here
			//
		}

	protected:
		/// <summary>
		/// Clean up any resources being used.
		/// </summary>
		~frmLog()
		{
			if (components)
			{
				delete components;
			}
		}
	private: System::Windows::Forms::ListBox^  lstLog;
	private: System::Windows::Forms::Timer^  tmrRefreshLog;

	private: System::ComponentModel::IContainer^  components;
	protected: 

	private:
		/// <summary>
		/// Required designer variable.
		/// </summary>


#pragma region Windows Form Designer generated code
		/// <summary>
		/// Required method for Designer support - do not modify
		/// the contents of this method with the code editor.
		/// </summary>
		void InitializeComponent(void)
		{
			this->components = (gcnew System::ComponentModel::Container());
			this->lstLog = (gcnew System::Windows::Forms::ListBox());
			this->tmrRefreshLog = (gcnew System::Windows::Forms::Timer(this->components));
			this->SuspendLayout();
			// 
			// lstLog
			// 
			this->lstLog->FormattingEnabled = true;
			this->lstLog->Location = System::Drawing::Point(0, 0);
			this->lstLog->Name = L"lstLog";
			this->lstLog->Size = System::Drawing::Size(612, 160);
			this->lstLog->TabIndex = 15;
			this->lstLog->TabStop = false;
			// 
			// tmrRefreshLog
			// 
			this->tmrRefreshLog->Enabled = true;
			this->tmrRefreshLog->Interval = 1;
			this->tmrRefreshLog->Tick += gcnew System::EventHandler(this, &frmLog::tmrRefreshLog_Tick);
			// 
			// frmLog
			// 
			this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
			this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
			this->ClientSize = System::Drawing::Size(612, 161);
			this->Controls->Add(this->lstLog);
			this->Name = L"frmLog";
			this->StartPosition = System::Windows::Forms::FormStartPosition::CenterScreen;
			this->Text = L"TradeIt - Log";
			this->Load += gcnew System::EventHandler(this, &frmLog::frmLog_Load);
			this->Resize += gcnew System::EventHandler(this, &frmLog::frmLog_Resize);
			this->ResumeLayout(false);

		}
#pragma endregion

	private:
		Account ^account;

	private: System::Void frmLog_Load(System::Object^  sender, System::EventArgs^  e)
			 {
				 int i;

				 lstLog->Items->Clear();
				 for (i=0; i<account->Log()->Count; i++)
					 lstLog->Items->Insert(0, account->Log()[i]->ToString() );
			 }

	private: System::Void frmLog_Resize(System::Object^  sender, System::EventArgs^  e)
			 {
				 lstLog->Width = this->Width - 22;
				 lstLog->Height = this->Height - 40;
			 }

	private: System::Void tmrRefreshLog_Tick(System::Object^  sender, System::EventArgs^  e)
			 {
				 if (lstLog->Items->Count != account->Log()->Count)
				 {
					 int i;

					 lstLog->Items->Clear();
					 for (i=0; i<account->Log()->Count; i++)
						 lstLog->Items->Insert(0, account->Log()[i]->ToString() );
				 }
			 }

};
}
